<?php

namespace app\order\controller;

use app\api\logic\TestLogic;
use app\common\controller\PCBase;
use app\BaseController;
use app\order\logic\OrderCheckLogisticsLogic;
use app\order\logic\QcCheckLogic;
use app\order\logic\OrderShanHouLogic;
use app\order\logic\OrderDiFourLogic;
use think\facade\Db;
use Throwable;
use app\common\library\Upload;

class OrderCheckLogistics extends PCBase
{


    public function initialize(): void
    {
        parent::initialize();
    }

    

    /**
     * index
     * @throws Throwable
     */
    public function index()
    {
        $params     = $this->request->post();
        $OrderCheckLogisticsLogic = new OrderCheckLogisticsLogic();
        return $OrderCheckLogisticsLogic->index($params);
    }

    
    /**
     * 添加
     * @throws Throwable
     */
    public function add()
    {
        $post = $this->request->post();
        $AdvaccountlogLogic = new OrderCheckLogisticsLogic();
        $result = $AdvaccountlogLogic->add($post);
        return $result;
    }

    /**
     * 回显
     * @throws Throwable
     */
    public function find($id = null)
    {
        $post = $this->request->post();
        $id = $post['id'] ?? 0;
        $AdvaccountlogLogic = new OrderCheckLogisticsLogic();
        $result = $AdvaccountlogLogic->find($id);
        return $result;
    }
    /**
     * 编辑
     * @throws Throwable
     */
    public function edit()
    {
        $post = $this->request->post();
        $AdvaccountlogLogic = new OrderCheckLogisticsLogic();
        $result = $AdvaccountlogLogic->edit($post);
        return $result;
    }

    /**
     * export
     * @throws Throwable
     */
    public function export()
    {
        $params     = $this->request->post();
        $OrderCheckLogisticsLogic = new OrderCheckLogisticsLogic();
        return $OrderCheckLogisticsLogic->export($params);
    }

    /**
     * @desc   import
     * @author zhagnheng
     * @date   2024-08-23
     */
    public function importInfo(){
        $file         = $this->request->file('file');
        $tel          = $this->getAdminTel();
        $params       = $this->request->post();
        $type         = $params['type']??'';
        $data['file'] = $file;
        $data['tel']  = $tel;
        switch($type){
            case '1':
                //闪电猴
                (new OrderShanHouLogic())->import_hou_detail($data);
                break;
            case '2':
                //递四方
                (new OrderDiFourLogic())->import_fang_detail($data);
                break;
            case '3':
                //全程无忧
                (new QcCheckLogic())->import_qc_detail($data);
                break;
            case '4':
                //顺丰
                (new OrderCheckLogisticsLogic())->import_SF_detail($data);
                break;
            default:
                break;
        }
        return  $this->jsonMessage(200, true, '操作成功',null);

    }

    /**
     * 渠道列表
     * @throws Throwable
     */
    public function ChannelsList()
    {
        $params     = $this->request->post();
        $OrderCheckLogisticsLogic = new OrderCheckLogisticsLogic();
        return $OrderCheckLogisticsLogic->ChannelsList($params);
    }






















}
